import java.util.*;

public class PortalModel extends Models {
  private float _rotateRight;
  private float _rotateLeft;
  private float _translateLR;
  private float _translateUD;
  private color _color;

  public PortalModel(PVector p) {
    super(p, 1, new PVector(20, 100, 100));
    this._rotateRight = 0;
    this._rotateLeft = 0;
    this._translateLR = 0;
    this._translateUD = 0;
    this._color = color(128, 128, 128);
  }

  public void draw() {
    fill(this._color);
    stroke(190,190,190);
    pushMatrix();
    translate(this._pos.x, this._pos.y, this._pos.z);
    rotateY(radians(this._rotateLeft));
    rotateZ(radians(this._rotateRight));
    box(this._size.x, this._size.y, this._size.z);
    popMatrix();
    noStroke();
  }

  public void setRotateRight(float angle) {
    this._rotateRight = angle;
  }

  public void setRotateLeft(float angle) {
    this._rotateLeft = angle;
  }

  public void setTranslateLR(float offset) {
    this._translateLR = offset;
  }

  public void setTranslateUD(float offset) {
    this._translateUD = offset;
  }

  public void update() {
    this.setPosition(new PVector(this._pos.x, this._pos.y + this._translateLR, this._pos.z + this._translateUD));
  }

  public void setColor(color c) {
    this._color = c;
  }

  public PVector computeExitPortal(float teta, float phi){
    PVector newDir = new PVector(1, 1, 1);
    newDir.x = sin(teta)*cos(phi);   
    newDir.y = sin(teta)*sin(phi);
    newDir.z = cos(teta);
    
    return newDir;
  }
  
}

